import request from '@/utils/request'

export const getOrderListService = () => {
	return request.get('/order/all')
}

export const handleOrderService = (id, state) => {
	const params = new URLSearchParams()
	params.append('id', id)
	params.append('state', state)
	console.log(params)

	return request.patch('/order/handle', params)
}

export const submitOrderService = (order) => {
	return request.put('/order/submit', order)
}

export const getMyOrderListService = () => {
	return request.get('/order/myOrder')
}

export const getOrderListByStateService = (state) => {
	if (state == 'true') {
		return request.get('/order/allByState?state=true')
	} else if (state == 'false') {
		return request.get('/order/allByState?state=false')
	}
	return request.get('/order/all')
}
export const getOrderListByPageService = (params) => {
	return request.get('/order/allByPage', { params: params })
}
